<admintpl file="header" />
</head>
<body>
<div class="wrap">
	<form method="post" class="form-horizontal" id="pub_form" action="{:U('Admin/Prop/add_post')}"
		  enctype="multipart/form-data">
		<div class="control-group">
			<label class="span1 control-label" style="width: 90px;">*PK标题：</label>
			<div class="span3">
				<input type="text" name="title"  style="width: 556px;" value="{$news_info.title}">
			</div>
		</div>
		<div class="control-group">
			<label class="span1 control-label" style="width: 90px; color: red;">红方选手：</label>
			<div class="span3">
				<input type="text" name="red" id="red_name" style="width: 556px;" value="{$news_info.subtitle}" onfocus="show_red();">
				<input type="hidden" name="red_id" id="red_id" value="" >
			</div>
		</div>
		<div class="control-group">
			<label class="span1 control-label" style="width: 90px; color: deepskyblue;">蓝方选手：</label>
			<div class="span3">
				<input type="text" name="blue" id="blue_name" style="width: 556px;" value="{$news_info.keywords}" onfocus="show_blue();">
				<input type="hidden" name="blue_id" id="blue_id" value="" >
			</div>
		</div>
		<div id="show" style="display: none;">
			<table class="table table-hover table-bordered" style="width: 50%;">
				<thead>
				<tr>
					<th>选择</th>
					<th>序号</th>
					<th>姓名</th>
					<th>性别</th>
					<th>绰号</th>
				</tr>
				</thead>
				<tbody>
				<foreach name="competitor_list" item="vo" key="keys">
					<?php
					if($vo['sex'] == 1){
						$sex = '男';
					}else if($vo['sex'] == 2){
						$sex = '女';
					}
				?>
					<tr>
						<td><input type="radio" name="competitor" id="competitor_{$vo.competitor_id}" value="{$vo.competitor_id}" onchange="change('{$vo.competitor_id}',1)"></td>
						<td>{$keys+1}</td>
						<td id="id_{$vo.competitor_id}">{$vo.real_name}</td>
						<td>{$sex}</td>
						<td>{$vo.nickname}</td>
					</tr>
				</foreach>
				<tr>
					<td colspan="5" style="font-size: 16px;"><?php if ($page != 1) { //页数不等于1
					?>
						<a href="#" onclick="page('<?php echo $page-1;?>',1)">上一页</a> <!--显示上一页-->
						<?php
					}
					for ($i=1;$i<=$totalPage;$i++) {  //循环显示出页面
					?>
						<a href="#" onclick="page('<?php echo $i;?>',1)"><?php echo $i ;?></a>
						<?php
					}
					if ($page<$totalPage) { //如果page小于总页数,显示下一页链接
					?>
						<a href="#" onclick="page('<?php echo $page+1;?>',1)">下一页</a>
						<?php
					}
					?>
					</td>
				</tr>
				</tbody>
			</table>
		</div>
		<div id="show_blue" style="display: none;">
			<table class="table table-hover table-bordered" style="width: 50%;">
				<thead>
				<tr>
					<th>选择</th>
					<th>序号</th>
					<th>姓名</th>
					<th>性别</th>
					<th>绰号</th>
				</tr>
				</thead>
				<tbody>
				<foreach name="competitor_list" item="vo" key="keys">
					<?php
					if($vo['sex'] == 1){
						$sex = '男';
					}else if($vo['sex'] == 2){
						$sex = '女';
					}
				?>
					<tr>
						<td><input type="radio" name="competitor1" id="competitor1_{$vo.competitor_id}" value="{$vo.competitor_id}" onchange="change('{$vo.competitor_id}',2)"></td>
						<td>{$keys+1}</td>
						<td id="id_{$vo.competitor_id}">{$vo.real_name}</td>
						<td>{$sex}</td>
						<td>{$vo.nickname}</td>
					</tr>
				</foreach>
				<tr>
					<td colspan="5" style="font-size: 16px;"><?php if ($page != 1) { //页数不等于1
					?>
						<a href="#" onclick="page('<?php echo $page-1;?>', 2)">上一页</a> <!--显示上一页-->
						<?php
					}
					for ($i=1;$i<=$totalPage;$i++) {  //循环显示出页面
					?>
						<a href="#" onclick="page('<?php echo $i;?>', 2)"><?php echo $i ;?></a>
						<?php
					}
					if ($page<$totalPage) { //如果page小于总页数,显示下一页链接
					?>
						<a href="#" onclick="page('<?php echo $page+1;?>', 2)">下一页</a>
						<?php
					}
					?>
					</td>
				</tr>
				</tbody>
			</table>
		</div>

		<input type="hidden" name="live_id" value="{$live_id}">
		<div class="form-actions" style="padding-left:260px;">
			<button type="button" id="quick_publish" class="btn">保存</button>
			&nbsp;&nbsp;
			<if condition="$type eq 2">
				<a class="btn" href="{:U('Admin/Special/index',array('news_id'=>$special_id,$id_type=>$id_val))}">{:L('BACK')}</a>
				<else/>
				<a class="btn" href="{:U('Admin/News/index?'.$id_type.'='.$id_val)}">{:L('BACK')}</a>
			</if>

		</div>
	</form>
</div>
<script src="__PUBLIC__/js/common.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/content_addtop.js"></script>

<script type="text/javascript" >
	function show_red() {
		$("#show_blue").css('display', 'none');
		$("#show").css('display', 'block');
		var blue = $("#blue_id").val();
		$("#competitor_"+blue).attr('disabled','disabled');
		$("#competitor_"+blue).attr('checked',false);
	}
	function change(id, group) {
		if(group == 1){
			groups = 'red';
			var blue = $("#blue_id").val();
			$("#competitor_"+blue).attr('disabled','disabled');
			$("#competitor_"+blue).attr('checked',false);
		}else{
			groups = 'blue';
			var red = $("#red_id").val();
			$("#competitor1_"+red).attr('disabled','disabled');
			$("#competitor1_"+red).attr('checked',false);
		}
		var name = $("#id_"+id).html();
		var ids = groups+'_id';
		var uname = groups+'_name';
		$("#"+ids).val(id);
		$("#"+uname).val(name);
	}
	function show_blue() {
		$("#show").css('display', 'none');
		$("#show_blue").css('display', 'block');
		var red = $("#red_id").val();
		$("#competitor1_"+red).attr('disabled','disabled');
		$("#competitor1_"+red).attr('checked',false);

	}
	function page(current_page, group) {
		$.ajax({
			type: "POST",
			cache: false,
			data: "page="+current_page+"&group="+group+"&type=2",
			async: false,
			url: "{:U('Prop/pages')}",
			success: function(ret) {
				if(group == 1){
					$("#show").html(ret);
					var blue = $("#blue_id").val();
					$("#competitor_"+blue).attr('disabled','disabled');
					$("#competitor_"+blue).attr('checked',false);
				}else{
					$("#show_blue").html(ret);
					var red = $("#red_id").val();
					$("#competitor1_"+red).attr('disabled','disabled');
					$("#competitor1_"+red).attr('checked',false);
				}
			}, error: function(data) {
				alert('网络错误，请稍后再试！');
			}
		});
	}
</script>
</body>
</html>